﻿@model Zor_Web.Models.Base.V_Zor_RepealJinSan
@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>金三销号</title>
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script language='javascript' src='~/Content/layer/layer.js'></script>
    <!-- 日期选择器 -->
    <script src="~/Content/LayerUI/src/layui.js"></script>  
</head>
<body>
    <div class="layui-tab layui-tab-brief main-tab-container ">  
            <div class="col-sm-12 ct-padding">               
                <button id="btnDelete" class="layui-btn  layui-btn-crimson layui-btn-small"><span class="glyphicon glyphicon-remove"></span> 销号</button> 
                <button id="btnSearch" class="layui-btn  layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span>查询 </button>          
                <button id="btnReplace" class="layui-btn layui-btn-blue layui-btn-small"> <span class="glyphicon glyphicon-refresh"></span>刷新 </button>                          
            </div>
     
        <div class="col-sm-12  layui-tab-content">
            <div class="mail-box" style="overflow-x:scroll;white-space:nowrap;">
                <table class="layui-table" lay-skin="line">
                    <thead>
                        <tr>
                            <th hidden></th>
                            <th></th>
                            <th>受理单号</th>
                            <th>业主姓名</th>
                            <th>身份证号</th>
                            <th>联系方式</th>
                            <th>税务登记号</th>
                            <th>付款人</th>
                            <th>产权</th>
                            <th>属性</th>
                            <th>面积</th>
                            <th>评定租金</th>
                            <th>税金</th>
                            <th>操作时间</th>
                            <th>受理状态</th>
                        </tr>
                    </thead>
                    <tbody id="accordion">
                        @foreach (var item in Model.PageData)
                    {
                        <tr>
                            <td hidden>@item.Js_Id</td>
                            <td><input type="radio" name="chk" id="@item.Js_Id" value="@item.Js_Id" /></td>
                            <td>@item.Acceptance_TicketNumber</td><!--受理单号2-->
                            <td>@item.NatPer_Name</td><!--业主姓名3-->
                            <td>@item.NatPer_IDNumber</td> <!--业主身份证号4-->
                            <td>@item.NatPer_Phone</td><!--业主电话5-->
                            <td>@item.Tenant_TaxRegistrationNum</td><!--税务登记号6-->
                            <td>@item.Tenant_Name</td><!--付款名称7-->
                            <td>@item.Hs_Cqsx</td><!--产权8-->
                            <td>@item.Hs_attribute</td><!--属性9-->
                            <td>@item.Hs_Proportion</td><!--房屋面积10-->
                            <td>@(item.Evaluate_Rent *0.01)</td><!--评定租金11-->
                            <td>@(item.Js_Tax *0.01)</td><!--税额12-->
                            <td>@TimeHelper.TimeStampToDateTime(item.Js_CreateDate.ToString(), TimeHelper.ToTimeType.link_ymd)</td>  <!--操作时间13-->
                            @if (@item.JsState == "发票已出")
                            {
                                <td style="color:red">@item.JsState</td>
                            }
                            else
                            {
                                <td>@item.JsState</td><!--金三受理状态14-->
                            }
                            <td hidden>@item.Acceptance_Id</td> <!--受理单ID15-->
                            <td hidden>@item.Js_State</td> <!--受理状态16-->
                        </tr>
                    }
                    </tbody>
                </table>

                <div class="row">
                    <div class="col-sm-9">
                        @Html.Pager(Model.PageData, new PagerOptions { PageIndexParameterName = "index", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>", PagerItemWrapperFormatString = "<li>{0}</li>" }, new { id = "", @class = "pagination" })
                    </div>
                    <div class="col-sm-3">
                        共 @Model.PageData.TotalItemCount 条记录，页 @Model.PageData.CurrentPageIndex/@Model.PageData.TotalPageCount
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 模态:查询 -->
    @using (Html.BeginForm("Zor_RepealJinSan", "Base", new RouteValueDictionary { { "Model", Model } }, FormMethod.Get))
    {
   <!--查询模态-->
    <div id="QueryModal" style="display: none;padding: 20px;">                   
        <form class="layui-form">
            <div class="layui-form-item" hidden>
                <label class="col-sm-3 layui-form-label">ID：</label>
                <div class="col-sm-9">
                    <input type="text" value="@Model.Js_Id" class="form-control">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="col-sm-3 layui-form-label">受理单号：</label>
                <div class="col-sm-9">
                    <input type="text" name="Acceptance_TicketNumber" value="@Model.Acceptance_TicketNumber" class="form-control">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="col-sm-3 layui-form-label">纳税人姓名：</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" name="NatPer_Name" value="@Model.NatPer_Name">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="col-sm-3 layui-form-label">付款方名称：</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" name="Tenant_Name" value="@Model.Tenant_Name">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="col-sm-3 layui-form-label">字轨票号：</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control" name="Js_Zigui" value="@Model.Js_Zigui">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="col-sm-3 layui-form-label">操作开始日：</label>
                <div class="col-sm-9">                  
                    @*<input class="laydate-icon form-control layer-date" id="Search_StartTime" placeholder="开始日" name="CreateStartTime" value="@Model.CreateStartTime">*@  
                    <input class=" layui-input startEndData" name="CreateStartTime" placeholder="开始日" data-type="开始日" id="startDate" value="@Model.CreateStartTime">                               
                </div>
            </div>
            <div class="layui-form-item">
                <label class="col-sm-3 layui-form-label">操作截止日：</label>
                <div class="col-sm-9">                                     
                  @*<input class="laydate-icon form-control layer-date" id="Search_EndTime" placeholder="截止日" name="CreateEndTime " value="@Model.CreateEndTime">*@
                    <input class="layui-input startEndData" name="CreateEndTime" placeholder="截止日" data-type="截止日" id="startDate" value="@Model.CreateEndTime">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="col-sm-3 layui-form-label">受理状态：</label>
                <div class="col-sm-9">
                    <select class="form-control" name="JsState">
                        <option value="全部" selected>全部</option>
                        <option value="@Model.JsState">已保存</option>
                        <option value="@Model.JsState">发票已出</option>
                        <option value="@Model.JsState">已销号</option>
                    </select>
                </div>
            </div>
        </form>
       <div class="box-footer">
                <button type="submit" id="btnQuery" class="btn btn-info pull-right">
                    <i class="fa fa-search"></i>查询
                </button>
            </div>                      
   </div>
 }
</body>
</html>
<script>
    /**
    * 日期选择器
    */
    layui.use(['element', 'layer', 'form', 'laydate'], function () {
        var element = layui.element(),
        jq = layui.jquery,
        form = layui.form(),
        laydate = layui.laydate;

        var start = {
            max: '2099-06-16 23:59:59',
            istoday: false,
            choose: function (datas) {
                end.min = datas;     //开始日选好后，重置结束日的最小日期
                end.start = datas    //将结束日的初始值设定为开始日
            }
        };

        var end = {
            max: '2099-06-16 23:59:59',
            istoday: false,
            choose: function (datas) { start.max = datas; }  //结束日选好后，重置开始日的最大日期        
        };
        jq('.startEndData').on('click', function () {
            var type = jq(this).data('type');
            if (type == "开始日") {
                start.elem = this;
                laydate(start);
            }
            else {
                end.elem = this
                laydate(end);
            }
        })
    })

    /**
     * 销号
   **/
    $(function () {
        $("#btnDelete").click(function () {
            var checkId = CheckboxValueIDs();
            var Acceptance_Id = getTableCell(15);    //受理单ID
            var JsState = getTableCell(14);    //受理状态
            if (checkId.length == 0) {
                layer.msg("请选择要销号的受理单！");                 //未选中任何行
                return;
            }
            if (checkId.length > 1)
            {
                layer.msg("只能选择一条信息销号！");                 //选中多行记录
                return;
            }
            if (JsState == "已保存") {
                layer.msg("当前受理单未缴税，不能销号！");                 //已销号记录，不能再销号
                return;
            }
            if (JsState == "已销号")
            {
                layer.msg("当前受理单已经销号！");                 //已销号记录，不能再销号
                return;
            }            
            else {
                layer.confirm("确定要销号吗?", { icon: 2, btn: ['确定', '取消'] }, function () {
                    ZorPostSimpleData("/Base/RepealJinSan", JSON.stringify({ 'Jsid': checkId[0], 'AcceptanceId': Acceptance_Id }), function (data) { //获取数据(带参数)
                        layer.msg(data.AnswerMeg, function () {
                            layer.closeAll();
                            Replace();
                        });
                    })
                })
            }
        })
    })
    /**
      * 查询
    **/
    $(function () {
        $("#btnSearch").click(function () {
            LayerOpen('550px', '440px', '查询条件', $('#QueryModal'));//打开查询信息模态框          
        })
    })
    /**
   * 刷新
   **/
    $(function () {
        $("#btnReplace").click(function () {
            Replace();
        })
    })
</script>